/*jadclipse*/// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.

package com.kingdee.bos.waf.workflow;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.bos.metadata.IMetaDataPK;
import com.kingdee.bos.waf.action.ActionManager;
import com.kingdee.bos.waf.ctx.WafContext;
import com.kingdee.bos.waf.winlet.CoreBaseBean;
import com.kingdee.bos.workflow.ProcessInstInfo;
import com.kingdee.bos.workflow.WfException;
import com.kingdee.bos.workflow.service.ormrpc.EnactmentServiceFactory;
import com.kingdee.bos.workflow.service.ormrpc.IEnactmentService;
import com.kingdee.eas.basedata.org.OrgUnitInfo;
import com.kingdee.util.StringUtils;
import java.net.URLEncoder;
import java.util.*;
import org.apache.log4j.Logger;
import org.operamasks.faces.annotation.Bind;
import org.operamasks.faces.annotation.ManagedBean;
import org.operamasks.faces.annotation.ManagedBeanScope;
import org.operamasks.faces.component.widget.UIButton;

// Referenced classes of package com.kingdee.bos.waf.workflow:
//            WfWafUtil
@ManagedBean(name = "workflow.viewProcessDiagramWlBean", scope = ManagedBeanScope.SESSION)
public class ViewProcessDiagramWlBean extends CoreBaseBean
{

            public ViewProcessDiagramWlBean()
            {
            }

            protected void beforeRender(boolean isPostBack)
            {
/*  57*/        if(isPostBack)
/*  58*/            return;
/*  60*/        viewPageUrl = null;
/*  61*/        Context ctx = WafContext.getInstance().getContext();
/*  62*/        locale = ctx.getLocale();
/*  65*/        procInstId = WfWafUtil.getParameter("proInstId", true);
/*  66*/        if(procInstId == null)
                {
					try {
/*  67*/            IEnactmentService service;
					
					service = EnactmentServiceFactory.createRemoteEnactService();
/*  68*/            String assignmentId = WfWafUtil.getParameter("assignmentId", true);
/*  70*/            if(assignmentId != null)
                    {
						procInstId = service.getProcessInstInfoByAssign(assignmentId).getProcInstId();
						procCode=service.getProcessInstInfo(procInstId).getCode();
                    } else
                    {
/*  74*/                String bizId = WfWafUtil.getParameter("billId", true);
                        billId=bizId;
						procInstId = WfWafUtil.getProcInstId(bizId);
						procCode=service.getProcessInstInfo(procInstId).getCode();
                    }
					if(procInstId != null && service.getProcessInstInfo(procInstId).getState().startsWith("close"))
					btnJump_binding.setDisabled(true);
					} catch (WfException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} catch (BOSException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
                }
/*  85*/        if(procInstId == null)
                {
/*  86*/            outerScript = (new StringBuilder()).append("alert('").append(ResourceBundle.getBundle(msgBuddle, locale).getString("errNoInst")).append("');window.close();").toString();
/*  89*/            return;
                }
/*  92*/        try
                {
/*  92*/            drawProcDiagram();
                }
/*  93*/        catch(Exception e)
                {
/*  94*/            outerScript = (new StringBuilder()).append("alert('").append(ResourceBundle.getBundle(msgBuddle, locale).getString("errInit")).append("');window.close();").toString();
/*  98*/            logger.error("load process info failed", e);
                }
/* 100*/        return;
            }

            private void drawProcDiagram()
                throws Exception
            {
/* 103*/        String notSelectActivity = ResourceBundle.getBundle(msgBuddle, locale).getString("notSelectActivity");
/* 104*/        notSelectActivity = URLEncoder.encode(notSelectActivity, "utf-8");
/* 105*/        notSelectActivity = StringUtils.replace(notSelectActivity, "+", "%2B");
/* 106*/        viewPageUrl = (new StringBuilder()).append("./viewProcInstDiagram.jsp?procInstId=").append(procInstId).append("&t=").append(UUID.randomUUID().toString()).append("&notSelectActivity=").append(notSelectActivity).toString();
/* 110*/        boolean hasParentProc = false;
/* 111*/        if(procInstId.endsWith("WFPCINST"))
                {
/* 112*/            parentProcInstId = WfWafUtil.getWfService().getProcessInstInfo(procInstId).getParentProcInstId();
/* 114*/            hasParentProc = parentProcInstId != null && parentProcInstId.length() > 0;
                } else
                {
/* 117*/            outerScript = "flag=true;disabledAllButtons();";
                }
/* 121*/        if(WfWafUtil.getParameter("hide_parent", false) == null);
/* 125*/        btnShowParentDiagram.setDisabled(!hasParentProc);
            }

            public void refresh()
                throws Exception
            {
/* 129*/        boolean b = btnShowParentDiagram.isDisabled();
/* 130*/        drawProcDiagram();
/* 131*/        if(b)
/* 131*/            btnShowParentDiagram.setDisabled(b);
/* 133*/        outerScript = (new StringBuilder()).append("document.getElementById('imgFrame').src='").append(viewPageUrl).append("';").toString();
            }

            public static final String msgBuddle = com.kingdee.bos.waf.workflow.ViewProcessDiagramMBean.class.getName();
            static final Logger logger = Logger.getLogger(com.kingdee.bos.waf.workflow.ViewProcessDiagramMBean.class);
            @Bind
            String viewPageUrl;
            @Bind
            String procInstId;
            @Bind
            String billId;
            @Bind
            String procCode;
            @Bind
            String outerScript;
            @Bind
            String parentProcInstId;
            @Bind
            UIButton btnShowParentDiagram;
            @Bind
            Locale locale;
            @Bind(id="btnJump")
            private UIButton btnJump_binding;
			public ActionManager getActionManager() {
				// TODO Auto-generated method stub
				return null;
			}

			public OrgUnitInfo getMainOrgInfo() {
				// TODO Auto-generated method stub
				return null;
			}

			public IMetaDataPK getMetaDataPK() {
				// TODO Auto-generated method stub
				return null;
			}

}
